#include <iostream>
#include <string>
#include <sys/types.h>
#include <signal.h>


int main(int argc, char* argv[])
{
    //命令行参数不多于三个
    if(argc!=3)
    {
        std::cout<<"./mykill signalnumber pid:"<<std::endl;
        return 1;
    }

    //将命令行参数转换为数字
    int signalnum = std::stoi(argv[1]);
    pid_t target = std::stoi(argv[2]);

    //向目标进程发送信号
    int n = kill(target, signalnum);

    //发送成功
    if(n==0)
    {
        std::cout<<"send "<<signalnum<<" to "<<target<<" success."<<std::endl;
    }

    return 0;
}